function oBlur_1() {
    let a = document.getElementById("softwareName").value;
    if (a == "") {
        document.getElementById("remind_1").innerHTML = "软件名不能为空！".fontcolor("red");
        document.getElementById("change_margin_1").style.marginBottom = 1 + "px";
    } else {
        document.getElementById("remind_1").innerHTML = "";
        document.getElementById("change_margin_1").style.marginBottom = 19 + "px";
    }
}

function oFocus_1() {
    document.getElementById("remind_1").innerHTML = "";
    document.getElementById("change_margin_1").style.marginBottom = 19 + "px";
}

/*function BrowseFolder() {
    try {
        var Message = "请选择文件路径.";  //选择框提示信息
        var Shell = new ActiveXObject("Shell.Application");
        var Folder = Shell.BrowseForFolder(0, Message, 0x0040, 0x11); //起始目录为：我的电脑
        //var Folder = Shell.BrowseForFolder(0,Message,0); //起始目录为：桌面
        if (Folder != null) {
            Folder = Folder.items();  // 返回 FolderItems 对象
            Folder = Folder.item();  // 返回 Folderitem 对象
            Folder = Folder.Path;   // 返回路径
            if (Folder.charAt(Folder.length - 1) != "\\") {
                Folder = Folder + "\\";
            }
            $("#softwarePath").val(Folder);
        }
    } catch (e) {
        layer.alert(e.message);
    }
}*/
/*function BrowseFolder() {
	var selectedFile = document.getElementById('files');
	var name = selectedFile.value;//读取选中文件的文件名
//	alert(name);
	 $("#softwarePath").val(name);
}*/


window.onload = function(){

    var index = parent.layer.getFrameIndex(window.name);

    $('#saveSoftware').click(function () {
        var softwareName = $("#softwareName").val();
        var softwarePath = $("#softwarePath").val();

        if(softwareName==""||softwarePath==""){
            parent.layer.confirm('关键信息未全，不能添加！',{btn:['确定']});
        }else {
        	softwarePath=softwarePath.replace(/\\/g,"/");
//        	alert(softwarePath);
            $.ajax({
                url: constUrl + "MonitorSoftwareServlet",
                type: 'post',
                data: {
                    operateType: "add",
                    softwareName: softwareName,
                    softwarePath: softwarePath
                },
                dataType: 'json',
                success: function (dataText) {
                    console.log(dataText.result);
                    if (dataText.result) {
                        parent.layer.confirm('添加成功！', {
                            btn: ['确定']
                        }, function () {
                            parent.location.reload(index);
                            parent.layer.close(index);
                        })
                    }
                },

                complete: function () {
                },
                error: function () {

                }
            });
        }
    });

    $('#closeIframe').click(function(){
        parent.layer.close(index);
    });
}

